using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace DT.Map.Tools
{
    [Serializable]
    public class PlayerFrame
    {
        public String PlayerName
        {
            get
            {
                switch (team)
                {
                    case TeamName.ATeam:
                        return "A" + index.ToString();
                    case TeamName.BTeam:
                        return "B" + index.ToString();
                    default:
                        return "Player" + index.ToString();
                }
            }
        }
        public TeamName team = TeamName.None;
        public int index = 0;
        public Vector2 CurrentPos;
        [HideInInspector] public Vector2 SrcPos;
        [HideInInspector] public Vector2 TargetPos;
        public bool isHolding = false;
        // public List<FrameState> FrameStates = new List<FrameState>();

        public Vector3 GetWorldPosition(Vector2 pos)
        {
            return new Vector3(pos.x - DTConstDate.FILED_OFFSET.x, 0, pos.y - DTConstDate.FILED_OFFSET.y);
        }
        public Vector2Int GetFiledPos(Vector3 pos)
        {
            return new Vector2Int((int)(pos.x - DTConstDate.FILED_OFFSET.x), -(int)(pos.z - DTConstDate.FILED_OFFSET.y));
        }

        public void OnUpdate(float RoundTime)
        {
            CurrentPos = Vector2.Lerp(SrcPos, TargetPos, RoundTime);
        }
    }

    public class DTConstDate
    {
        public const int FOOTBALL_FILED_WIDTH = 147;
        public const int FOOTBALL_FILED_HEIGHT = 79;
        public static int FILED_POINT = 0;

        public static Vector2Int FILED_OFFSET
        {
            get
            {
                switch (FILED_POINT)
                {
                    case 0: //球场中心
                        return new Vector2Int((int)(FOOTBALL_FILED_WIDTH * 0.5f), (int)(FOOTBALL_FILED_HEIGHT * 0.5f));
                    case 1: //球场左上
                        return Vector2Int.zero;
                }
                return Vector2Int.zero;
            }
        }
    }

    [Serializable]
    public class FrameState
    {
        public int Duration;
        public int EventKey;
        public string StateName;
        [HideInInspector] public float Speed;
    }


    public enum TeamName
    {
        None, ATeam, BTeam
    }
}
